package org.expressme.webwind;

import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;

import org.greatstorm.action.GeneralAction;

/**
 * Internal class which holds object instance, method and arguments' types.
 * 
 * @author Michael Liao (askxuefeng@gmail.com)
 */
class Action {

	/**
	 * Object instance.
	 */
	public final Object instance;

	/**
	 * Method instance.
	 */
	public final Method method;

	/**
	 * Method's arguments' types.
	 */
	public final Class<?>[] arguments;

	/**
	 * set the request
	 */
	public Method setRequestMethod;

	public Action(Object instance, Method method) {
		this.instance = instance;
		this.method = method;
		this.arguments = method.getParameterTypes();

		// add by alex to make action have the ability to access the http
		// request object
		try {
			this.setRequestMethod = GeneralAction.class.getMethod("setRequest",
					HttpServletRequest.class);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
